using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class ModelNumberMap : EntityTypeConfiguration<ModelNumber>
    {
        public ModelNumberMap()
        {
            // Primary Key
            this.HasKey(t => t.MNID);

            // Properties
            this.Property(t => t.MNName)
                .IsRequired()
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("ModelNumber");
            this.Property(t => t.MNID).HasColumnName("MNID");
            this.Property(t => t.MID).HasColumnName("MID");
            this.Property(t => t.HospitalID).HasColumnName("HospitalID");
            this.Property(t => t.MNName).HasColumnName("MNName");

            // Relationships
            this.HasRequired(t => t.Manufacturer2)
                .WithMany(t => t.ModelNumbers)
                .HasForeignKey(d => d.MID);

        }
    }
}
